/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cxhd.pacs.model;

import com.jfinal.plugin.activerecord.Model;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class FileDetail extends Model<FileDetail> {

    public static final FileDetail dao = new FileDetail();

    public String saveInfo(String type, String name, String path, String size, String filesystem_fk) {

        set("name", name)
                .set("type", type)
                .set("path", path)
                .set("size", size)
                .set("filesystem_fk", filesystem_fk)
                .save();
        return getInt("pk") + "";
    }

    public FileDetail getFile(String fileId) {

        return findFirst("select a.path,b.base_path,a.type from file_detail a left join filesystem b on a.filesystem_fk=b.pk where a.pk=?", fileId);

    }

    public List<FileDetail> getDetail(String order_no) {

        return find("select * from file where order_no ='" + order_no + "'");
    }

    public List<FileDetail> getDetails(String order_no) {
        System.out.println(order_no + "\"select a.path,b.base_path,a.type from file a left join filesystem b on a.filesystem_fk=b.pk where a.pk in(?)");
        return find("select a.name,a.path,b.base_path,a.type from file_detail a left join filesystem b on a.filesystem_fk=b.pk where a.order_no ='" + order_no + "'");

    }
}
